import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;


public class MemViewerTM extends AbstractTableModel {
    private String[] columnNames = {"Name", "Ram(Byte)", "Rom(Byte"};
    private ArrayList<Object> data = null;

    public void setData(ArrayList<Object> data) {
    	this.data = data;
    }
    
    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
    	if ( data == null ) return 0;
        return data.size();
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
    	if ( null != data ) {
    		if (data.get(row) instanceof ArrayList)
    			return ((ArrayList<Object>)data.get(row)).get(col);
    	}
    	return null;
    }

    /*
     * JTable uses this method to determine the default renderer/
     * editor for each cell.  If we didn't implement this method,
     * then the last column would contain text ("true"/"false"),
     * rather than a check box.
     */
    public Class getColumnClass(int c) {
    	if ( null == getValueAt(0, c) )
    		return null;
        return getValueAt(0, c).getClass();
    }
}
